function swap(arr, i, j) {
  let temp = arr[i]
  arr[i] = arr[j]
  arr[j] = temp
}

function selectSort(arr) {
  if (arr.length < 1) {
    return arr
  }
  for (let i = 0; i < arr.length; i++) {
    let min = i
    for (let j = i + 1; j < arr.length; j++) {
      if (arr[j] < arr[i]) {
        min = j
      }
    }
    swap(arr, i, min)
  }
  return arr
}
